/*
* © 2010 Autodata Solutions Company. All Rights Reserved
* This source code is the confidential and proprietary information of Autodata Solutions Company.
* The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
* without the prior written consent of Autodata Solutions Company.
*/
Ext.ns('net.autodata.compare.editorial');
(function() {

    /**
    * This view is used to define how a EditorialDetailView is rendered
    * @class EditorialDetailView
    * @extends net.autodata.AbstractView
    * @namespace ca.autotrader.compare.editorial
    */
    var View = Ext.extend(net.autodata.AbstractView, {
        /**
        * @property templates
        * @type Object
        */
        templates: undefined,

        //override the Abstract constructor to allow this object to be created
        constructor: function() {
            View.superclass.ctor.apply(this, arguments);
        },

        /**
        * @method initTemplates
        */
        initTemplates: function() {
            var ts = this.templates || {};

            if (!ts.mainTpl) {
                ts.mainTpl = new Ext.XTemplate(
					'<h5>{title}</h5>',
					'<p>{summary}</p>',
					'<span rel="{url}" class="read-more">{readmore}</span>',
					{
					    compile: true,
					    disableFormats: true
					}
				);
            }

            this.templates = ts;

            View.superclass.initTemplates.apply(this, arguments);
        },

        /**
        * @method render
        */
        render: function() {
            View.superclass.render.apply(this, arguments);

            var panel = this.component;
            if (!panel) {
                return;
            }

            var body = this.component.el;
            this.templates.mainTpl.overwrite(body.dom, panel.getData() || { summary: panel.emptyText });
        }
    });

    net.autodata.compare.editorial.EditorialDetailView = View;
})();